import ability_featureability from '@ohos.ability.featureAbility'
export default {
    data: {
        title: 'World'
    },
    getCacheDirPromise(){
        console.log('success')
        var context = ability_featureability.getContext();
        context.getCacheDir()
            .then((data) => {
            console.info('success to getCacheDir:' + data);
        }).catch((error) => {
            console.error('failed to getCacheDir because ' + error.message);
        })
    },
    getCacheDirCallback(){
        console.log('success')
        var context = ability_featureability.getContext();
        context.getCacheDir((error, data)=>{
            if (error) {
                console.error('failed to getCacheDir because ' + JSON.stringify(error));
                return;
            }
            console.info('success to getCacheDir: ' + JSON.stringify(data))
        })
    },
    getFilesDirPromise(){
            var context = ability_featureability.getContext();
        context.getFilesDir()
        .then((data) => {
            console.info('success to getFilesDir:' + data);
        }).catch((error) => {
            console.error('failed to getFilesDir because ' + error.message);
        })
    },
    getFilesDirCallback(){
        var context = ability_featureability.getContext();
        context.getFilesDir((error, data)=>{
            if (error) {
                console.error('failed to getFilesDir because ' + JSON.stringify(error));
                return;
            }
            console.info('success to getFilesDir: ' + JSON.stringify(data))
        })
    },
    getExternalCacheDirPromise(){
        var context = ability_featureability.getContext();
        context.getExternalCacheDir((error, data)=>{
            if (error) {
                console.error('failed to getExternalCacheDir because ' + JSON.stringify(error));
                return;
            }
            console.info('success to getExternalCacheDir: ' + JSON.stringify(data))
        })
    },
    getExternalCacheDirCallback(){
        var context = ability_featureability.getContext();
        context.getExternalCacheDir((error, data)=>{
            if (error) {
                console.error('failed to getExternalCacheDir because ' + JSON.stringify(error));
                return;
            }
            console.info('success to getExternalCacheDir: ' + JSON.stringify(data))
        })
    }
}
